﻿package fj.ui
{
	import flash.display.MovieClip
	import flash.events.MouseEvent;
	
	public class FJCheckbox extends MovieClip
	{
		public var hit:MovieClip;
		
		private var _check:MovieClip;
		private var _selected:Boolean;
		
		public function FJCheckbox():void
		{
			_check = getChildByName( "check" ) as MovieClip;
			
			_check.visible = false;
			hit.buttonMode = true;
			
			hit.addEventListener( MouseEvent.CLICK, hitClick );
		}
		public function set selected( b:Boolean ):void
		{
			_selected = b;
			if( b ){
				_check.visible = true;
			} else {
				_check.visible = false;
			}
		}
		public function get selected():Boolean
		{
			return _selected;
		}
		private function hitClick( e:MouseEvent ):void
		{
			if( _selected ){
				selected = false;
			} else {
				selected = true;
			}
		}
	}
}